package com.shop.mapper;

import com.github.pagehelper.Page;
import com.shop.dto.CommentPageQueryDTO;
import com.shop.dto.CommentsDTO;
import com.shop.entity.Comments;
import com.shop.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentsMapper {
    @Insert("insert into comments(owner_id,from_id,from_name,from_avatar,content,create_time,update_time)" +
            "values (#{ownerId},#{fromId},#{fromName},#{fromAvatar},#{content},#{createTime},#{updateTime})")
    void save(Comments comments);

    /**
     * 根据商户id查询评论
     * @param ownerId
     * @return
     */
    List<Comments> getById(Long ownerId);

    /**
     * 删除评论
     * @param ownerId
     * @return
     */
    @Delete("delete from comments where id = #{id}")
    void delete(Long ownerId);


    // 查询所有
    @Select("select * from comments")
    List<Comments> list();

    Page<Comments> pageQuery(CommentPageQueryDTO commentPageQueryDTO);
}
